{include file="public/header" /}
<body style="background-color: #f1f1f1;">
<div class="index_html houtai">

    {include file="public/second_header" /}


    <!-- 地下内容的开始 -->
    <div class="backgroud_content ">
        <!-- 左侧的开始 -->

        {include file="public/nav" /}
        <!-- 左侧的结束 -->


        <!-- 右侧的开始 -->
        <div class="right_bar jianchajilu hou_huanzheguanli hou_yonghuguanli">
            {include file="public/go_back" /}

            <div class="jcjl_detail">
                <div class="top_dec">
                    <div>
                        <span class="theme">用户列表</span>
                        <form action="{:url('Wx/send_msg')}" class="horizontal" method="post" role="form">
                            <input name="selectuser" value="" id="selectuser" hidden>
                            <!--   <em style="cursor: pointer;">
                               <input type="button" id="sendbtn" class="ajax-post" value="发布短信">-->
                                <!--<a id="sendbtn">发布短信</a>
                            </em>-->
                        </form>
                    </div>
                </div>
                <div class="data">
                    <form action="{:url('Wx/user_list')}" method="get"><!-- 下面是搜索  -->

                        <div class="search_box">
                            <!-- 开始日期 -->
                            <div class="date_box start_date">
                                <script type="text/javascript">
                                    $(function () {
                                        $('.end_date_picker').date_input();
                                    })
                                </script>
                                <div style="">
                                    <input style="" type="text" name="start" class="end_date_picker"
                                           value="{$search['start']?? ''}" id="start_date">
                                </div>
                            </div>
                            <!-- 开始的日期结束 -->

                            <!-- 结束日期 -->
                            <div class="date_box end_date">
                                <script type="text/javascript">
                                    $(function () {
                                        $('.end_date_picker').date_input();
                                    })
                                </script>
                                <div style="">
                                    <input style="" name="end" type="text" class="end_date_picker"
                                           value="{$search['end']?? ''}" id="end_date">
                                </div>

                            </div>
                            <!-- 结束的日期结束 -->
                            <!-- 输入  查找姓名 -->
                            <div class="search_by_name">
                                <input type="text" name="name" value="{$search['name']?? ''}" placeholder="查找昵称或ID">
                                <input type="submit" value="" class="search_btn"/>
                            </div>

                        </div>
                    </form>
                    <!-- 日历的输入  开始 -->
                    <!-- 下面的   列表 开始  -->
                    {if condition="!$list->isEmpty()"}
                    <div class="liebiao">

                        <div class="liebiao_dec">
                            <div class="liebiao_top">
                               <!-- <input class="first" type="checkbox" id="chkAll" onclick="selectAll(this)"/>全选/全取消<br/>-->

                                <strong class="first" style="margin-left: 25px;">用户ID</strong>
                                <strong class="second">用户昵称</strong>
                                <strong class="third">性别</strong>
                                <strong class="forth">成员数量</strong>
                                <strong class="fifth">检查记录</strong>
                                <strong class="sixth">注册时间</strong>
                                <strong class="seventh">操作</strong>
                            </div>
                            <ul>
                                {foreach $list as $user}


                                <li>
                                  <!--  <input type="checkbox" name="user" value="{$user.id}">-->
                                    <span class="first">
											<em>{$user.id}</em>
										</span>
                                    <span class="second">
											<em>{$user.name}</em>
										</span>
                                    <span class="third">
											<em>{$user.sex|get_sex_str}</em>
										</span>
                                    <span class="forth">
											<em>{$user.family_count}</em>
										</span>
                                    <span class="fifth">
											共{$user.record_count}条检查记录
										</span>
                                        <span class="sixth">
                                            {$user.create_time}
										</span>
										<span class="seventh">
											<a class="btn-permission" data-url="wx/user_family_list" href="{:url('Wx/user_family_list',array('uid'=>$user.id))}">查看</a>

                                             <!--   {if condition="$user['is_deleted'] eq 1"}
                                            <a  class="a-post"  data-url="wx/del_user" post-msg="你确定要禁用吗" post-url="{:url('Wx/del_user',array('id'=>$user['id'],'is_deleted'=>2))}">

                                            <input type="button" class="btn-permission" value="禁用">
                                                 {elseif condition="$user['is_deleted'] eq 2" /}
                                                <a  class="a-post"  data-url="wx/del_user" post-msg="你确定要启用吗" post-url="{:url('Wx/del_user',array('id'=>$user['id'],'is_deleted'=>1))}">

                                                <input type="button" class="btn-permission" value="启用">
                                                 {/if}
                                             </a>
											 <a  class="a-post"  data-url="wx/del_user" post-msg="你确定要删除吗" post-url="{:url('Wx/del_user',array('id'=>$user['id']))}">


                                                 <input type="button" class="btn-permission" value="删除">
                                             </a>-->
										</span>
                                </li>
                                {/foreach}
                            </ul>
                        </div>
                    </div>
                    <!-- 列表的结束 -->
                    <!-- 列表的结束 -->

                    {include file="public/page" /}
                    {else/}
                    暂无记录
                    {/if}
                </div>
            </div>
        </div>
        <!-- 右侧的结束 -->
    </div>
</div>
<script type="text/javascript">
    //设置选中的人员值
    function setselectuser() {
        var selectItem = new Array();
        $("input[name='user']:checked").each(function () {
            selectItem.push($(this).val());// 在数组中追加元素
        });
        $("#selectuser").val(selectItem.join(","));

    }
    //全选全取消
    function selectAll(checkbox) {
        $('input[type=checkbox]').prop('checked', $(checkbox).prop('checked'));
        setselectuser();
    }
    //提交之前设置一下
    $("#sendbtn").click(function () {
        setselectuser();
    });

    //给所有的 子checkbox注册事件，如果所有的子checkbox都打勾了，则全选也打勾
    window.onload = function () {

        var inputs = document.getElementsByTagName("input");
        for (var i = 0; i < inputs.length; i++) {
            if (inputs[i].type == "checkbox") {
                //去掉全选的那个chexkbox
                if (inputs[i].id != "chkAll") {
                    //给每个子checkbox注册事件
                    inputs[i].onclick = function () {
                        //判断子checkbox是不是被选中了
                        //假设所有的都被选中
                        var isCheckAll = true;
                        for (var j = 0; j < inputs.length; j++) {
                            if (inputs[j].type == "checkbox" && inputs[j].id != "chkAll") {
                                //判断子的checkbox是否被选中
                                if (!inputs[j].checked) {
                                    isCheckAll = false;
                                    break;
                                }
                            }
                        }
                        //设置全选状态
                        document.getElementById("chkAll").checked = isCheckAll;
                        setselectuser();

                    }
                }

            }

        }
    }
</script>
{include file="public/footer" /}